package com.asd.system.mapper;

import com.asd.system.entity.UserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 用户角色表 Mapper 接口
 * </p>
 *
 * @Author scott
 * @since 2018-12-21
 *
 */
@Mapper
@Component
public interface UserRoleMapper extends BaseMapper<UserRole> {

	@Select("select role_code from role where id in (select roleId from user_role where userId = (select id from user where userName=#{username}))")
	List<String> getRoleByUserName(@Param("username") String username);

	@Select("select id from role where id in (select roleId from user_role where userId = (select id from user where userName=#{username}))")
	List<String> getRoleIdByUserName(@Param("username") String username);

	@Select("select * from user_role where userId = #{userId} ")
    UserRole findByUserId(@Param("userId") String userId);
}
